import React, { ReactNode } from 'react'
import { TreeSelect } from 'antd'
import { TreeSelectProps } from 'antd/lib/tree-select'

export default function UdTreeSelect(props: IUdTreeSelectProps) {
  const { treeData, className, children, ...rest } = props
  return (
    <TreeSelect
      className={className}
      getPopupContainer={(triggerNode) => triggerNode}
      treeData={treeData}
      showCheckedStrategy={TreeSelect.SHOW_PARENT}
      {...rest}
    >
      {!treeData && props.children}
    </TreeSelect>
  )
}

interface IUdTreeSelectProps extends TreeSelectProps<any> {
  children?: ReactNode
}